@include('admin._include.header')
<style>
    .layui-tab-title {
        left: 25px;
    }
</style>

<body style="background: #fff">
<div class="layui-fluid">

<div class="layui-tab" lay-filter="demo">
    <ul class="layui-tab-title">
        <li class="layui-this">项目简介</li>
        <li>联系店长</li>
        <li>运营资质</li>
    </ul>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">

            <div class="layui-row larryms-panel auth-user-add">
                <form class="layui-form" method="post">

                    <div class="layui-form-item">
                        <label class="layui-form-label">项目标语</label>
                        <div class="layui-input-inline" style="width: 450px">
                            <input type="text" name="pro_keywords" placeholder="请填写项目标语" value="{{$model->pro_keywords}}"
                                   autocomplete="off" class="layui-input larry-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">项目简介</label>
                        <div class="layui-input-inline" style="width: 450px">
                            <textarea name="pro_description" class="layui-textarea" id="" placeholder="请填写项目简介" cols="30" rows="10">{{$model->pro_description}}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">项目介绍</label>
                        <div class="layui-input-inline" style="width: 450px">
                            <textarea name="pro_content" class="layui-textarea" id="lay_edit" placeholder="请填写项目介绍" cols="30" rows="10">{{$model->pro_content}}</textarea>
                        </div>
                    </div>


                    <div class="layui-form-item" >
                        <label class="layui-form-label"></label>
                        <button class="layui-btn" lay-submit lay-filter="plate_add">确定</button>
                    </div>

                </form>
            </div>

        </div>
        <div class="layui-tab-item">

            <div class="layui-row larryms-panel auth-user-add">
                <form class="layui-form" method="post">

                   
                    <div class="layui-form-item">
                        <label class="layui-form-label">店长姓名</label>
                        <div class="layui-input-inline" style="width: 450px">
                            <input type="text" name="shop_nick_name" placeholder="请填写店长姓名" value="{{$model->shop_nick_name}}"
                                   autocomplete="off" class="layui-input larry-input">
                        </div>
                    </div>


                    <div class="layui-form-item">
                        <label class="layui-form-label">店长手机号</label>
                        <div class="layui-input-inline" style="width: 450px">
                            <input type="text" name="shop_mobile" placeholder="请填写店长手机号" value="{{$model->shop_mobile}}"
                                   autocomplete="off" class="layui-input larry-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">店长微信号</label>
                        <div class="layui-input-inline" style="width: 450px">
                            <input type="text" name="shop_wechat" placeholder="请填写店长微信号" value="{{$model->shop_wechat}}"
                                   autocomplete="off" class="layui-input larry-input">
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">店长头像</label>
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn images_upload">上传图片</button>
                            <img class="layui-upload-img smallimg" src="{{$model->shop_avatar}}" style="width: 100px;">
                            <input type="hidden" name="shop_avatar" value="{{$model->shop_avatar}}">
                        </div>
                    </div>
                    
                    <div class="layui-form-item">
                        <label class="layui-form-label">店长微信二维码</label>
                        <div class="layui-input-inline">
                            <button type="button" class="layui-btn images_upload">上传图片</button>
                            <img class="layui-upload-img smallimg" src="{{$model->shop_wechat_code}}" style="width: 100px;">
                            <input type="hidden" name="shop_wechat_code" value="{{$model->shop_wechat_code}}">
                        </div>
                    </div>


                    <div class="layui-form-item" >
                        <label class="layui-form-label"></label>
                        <button class="layui-btn" lay-submit lay-filter="plate_add">确定</button>
                    </div>

                </form>
            </div>

        </div>
        <div class="layui-tab-item">

            <div class="layui-row larryms-panel auth-user-add">
                <form class="layui-form" method="post">


                    <div class="layui-form-item">
                        <label class="layui-form-label">运营资质</label>
                        <div class="layui-input-inline" style="width: 450px">
                            <textarea name="operate" class="layui-textarea" id="lay_edit2" placeholder="请填写运营资质" cols="30" rows="10">{{$model->operate}}</textarea>
                        </div>
                    </div>

                    <div class="layui-form-item" >
                        <label class="layui-form-label"></label>
                        <button class="layui-btn" lay-submit lay-filter="plate_add">确定</button>
                    </div>

                </form>
            </div>

        </div>
    </div>
</div>
</div>


<script>
    layui.config({
        base: "/plugin/layuiadmin/"  //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'upload','table', 'layedit'], function () {
        var $ = layui.$,
            form = layui.form,
            upload = layui.upload;

        var layedit = layui.layedit;
        layedit.set({	//设置图片接口
            uploadImage: {
                url: "{{url('public/lay-upload')}}", //接口url
                type: 'post'
            }
        });
        //创建一个编辑器，lay_edit为textarea标签的id值
        var pro_content = layedit.build('lay_edit',{
            height: 350    //设置编辑器的高度
        });


        var operate = layedit.build('lay_edit2',{
            height: 350    //设置编辑器的高度
        });


        form.on('submit(plate_add)', function (data) {

            var form = data.field;
            form.pro_content = layedit.getContent(pro_content);
            form.operate = layedit.getContent(operate);

            var index = layer.load(1);
            $.ajax({
                url: "{{url('platform/index')}}",
                dateType: 'json',
                data: data.field,
                type: 'post',
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                success: function (res) {
                    layer.close(index);
                    layer.msg(res.message);
                }
            });

            return false;
        });

        upload.render({
            elem: $('.images_upload'),
            url: '{{url('api/public/upload')}}',
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },
            multiple: false,  //是否允许多图上传
            accept: 'image',  //指定允许上传时校验的文件类型，可选值有：images（图片）、file（所有文件）、video（视频）、audio（音频）
            acceptMime: 'image/*',
            field: 'file',  //上传文件参数名
            before: function (obj) {
                index_upload = layer.load(1);
            },
            done: function (res) {
                layer.close(index_upload);
                if (res.status != SUCCESS) {
                    return layer.msg(res.message);
                } else {
                    let that = $(this.item);
                    that.next().next().attr('src', res.data);
                    that.next().next().next().val(res.data);
                }

                $(".smallimg").each(function () {
                    $(this).magnificPopup({
                        items: {
                            src: $(this).attr("src")
                        },
                        type: "image"
                    })
                });

            },
            error: function () {
                layer.close(index_upload);
            }
        });


    });

</script>
</body>
@include('admin._include.footer')